package de.maedn.server;

import java.util.HashMap;
import java.util.Map;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.json.simple.*;
import com.google.appengine.api.datastore.Key;

@Entity
public class User implements JSONAware {
	
	@Override
	public String toString() {
		return "User [key=" + key + ", account=" + account + ", name=" + name
				+ ", inGame=" + inGame + "]";
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key key;

	private String account;
	private String name;
	private Long inGame;

	public Long getInGame() {
		return inGame;
	}

	public void setInGame(Long inGame) {
		this.inGame = inGame;
	}

	public User() {
	}
	
	public User(String account, String name) {
		this.account = account;
		this.name = name;
		this.inGame = new Long(-1);
	}
	
	public String getAccount() {
		return account;
	}
	
	public Key getKey() {
		return key;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String toJSONString() {
		/*JSONObject object = new JSONObject();
		object.put("account", account);
		object.put("name", name);
		return JSONValue.toJSONString(object);*/
		Map<String, Object> map = new HashMap<String, Object>();
		//Map map = new HashMap();
		map.put("account", account);
		map.put("name", name);
		return JSONValue.toJSONString(map);
	}

}
